unit UReihenTool;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ExtCtrls, UMap, URender, UPictureList, UPictureName,
  StdCtrls, TypInfo, UMapObjekte;

type
  TReihenToolForm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    RefreshTimer: TTimer;
    ErstellenBtn: TButton;
    YEdit: TEdit;
    CountEdit: TEdit;
    XEdit: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    procedure RefreshTimerTimer(Sender: TObject);
    procedure ErstellenBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ReihenToolForm: TReihenToolForm;

implementation

uses UMapEditorForm;
{$R *.dfm}

procedure TReihenToolForm.ErstellenBtnClick(Sender: TObject);
var
  StartObj: TMapObject;
  x, y: integer;
  i: integer;
begin
  if MapEditorForm.GetDragObject <> nil then
  begin
    StartObj := MapEditorForm.GetDragObject;
    x := strtoint(self.XEdit.Text);
    y := strtoint(self.YEdit.Text);

    for i := 1 to strtoint(self.CountEdit.Text) do
    begin
      MapEditorForm.NewObjektAt(StartObj.StartX + (i * x), StartObj.StartY +
          (i * y), StartObj.PictureName);
    end;
  end;
end;

procedure TReihenToolForm.RefreshTimerTimer(Sender: TObject);
begin
  if MapEditorForm.GetDragObject = nil then
  begin
    self.Label1.Enabled := True;
    self.Label2.Enabled := False;
    self.Label3.Enabled := False;
    self.Label4.Enabled := False;
    self.Label5.Enabled := False;

    self.XEdit.Enabled := False;
    self.YEdit.Enabled := False;
    self.CountEdit.Enabled := False;
    self.ErstellenBtn.Enabled := False;
  end
  else
  begin
    self.Label1.Enabled := False;
    self.Label2.Enabled := True;
    self.Label3.Enabled := True;
    self.Label4.Enabled := True;
    self.Label5.Enabled := True;

    self.XEdit.Enabled := True;
    self.YEdit.Enabled := True;
    self.CountEdit.Enabled := True;
    self.ErstellenBtn.Enabled := True;
  end;
end;

end.
